import requests
from lxml import etree
import time

url = 'http://bizhi360.com/dongman/list_2.html'
resp = requests.get(url)
resp.encoding = 'utf-8'
tree = etree.HTML(resp.text)
content = tree.xpath('/html/body/div[3]/div/div[1]/ul')


for i in content:
    download_url = i.xpath('./li/a/@href')
    pic_name = i.xpath('./li/a/p/text()')

for a,b in zip(pic_name,download_url):
    b = 'http://bizhi360.com/' + b.rstrip('/')
    resp2 = requests.get(b)
    resp2.encoding = 'utf-8'
    tree2 = etree.HTML(resp2.text)
    # 注 意：这里download_href 不能 从 抓包工具 里复制路径，因为网页源代码和抓包工具里的代码有不同
    download_href = iter(tree2.xpath('/html/body/div[3]/div/div[1]/div[1]/a[3]/@href'))
    # 注 意：图片一定要有 ‘.jpg’ 后缀
    with open('../彼岸壁纸/' +a+'.jpg',mode='wb') as f:
        resp3 = requests.get(download_href.__next__())
        f.write(resp3.content)
    print(a, 'over!')
    time.sleep(1)